<?php 

namespace app\web\controller;

use app\common\hrlper\VerifyHelper;
use think\Controller;
use think\Db;
use think\Request;
use think\Session;


class TestController extends Controller
{
	// 首页
	public function index()
	{
		return view('index/app');
	}
	// 接口
	public function api()
	{
		$res = Db::table('my_user') ->field('username') ->select();
		return json($res);
	}
	
	public function verify()
	{
		VerifyHelper::verify();
	}

	//接口
	public function callapi()
	{
		$url = 'http://tp.local/api';
		$urlreq = new allRequest();
		$msg = $urlreq ->curl_request($url);
		dump(json_decode($msg));die;
	}

	// 门店
	public function store()
	{
		$data = model('TestModel') ->store();
		// var_dump($data);
		return view('index/store',[
			'list' => $data
		]);
	}

	public function search()
	{
		// var_dump($_POST);die;
		$data = model('TestModel') ->search();
		return view('index/store',[
			'list' => $data
		]);
	}

	public function menu()
	{	
			$res = Db::table('goods')->select();
			$list = Db::table('category')->where('pid',0)->select();
			// var_dump($res);
			// var_dump($list);
			return view('index/menu',[
				'list'=>$list,
				'res'=>$res
			]);
	}

	public function showgoods($id)
	{
		$list = model('TestModel') ->menu();
		$data = Db::table('category')->field('id')->where(' path like "%,'.$id.',%"')->select();
		// var_dump($data);die;
		$cid = '';
		foreach ($data as $k => $v) {
			$cid .= $v['id'].',';
		}
		$cid .= $id;
		$res = Db::table('goods')->where('goods_categroy_id in ('.$cid.')')->select();
		return view('index/menu',[
			'list'=>$list,
			'res'=>$res
		]);
	}


	public function more()
	{
		return view('index/more');
	}
}









